# -*- coding: utf-8 -*-
"""
@Project: base_python
@File: scrapetest.py
@Author: PC
@Date: 2025/04/29
@Description: 
"""

from urllib.request import urlopen
from urllib.error import HTTPError
from urllib.error import URLError
from bs4 import BeautifulSoup

try:
    html = urlopen('http://pythonscraping.com/pages/page11.html')
    # html = urlopen('http://pythonscraping.compages/page11.html')
    bs = BeautifulSoup(html, 'lxml')
except HTTPError as e:
    print(e)
except URLError as e:
    print('The server could not be found!')
else:
    try:
        badContent = bs.nonExisting.anotherTag
    except AttributeError as e:
        print('Tag was not found')
    else:
        if badContent == None:
            print('Tag was not found')
        else:
            print(badContent)
